package com.hm.service.config.redis;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

@Configuration
public class jedisPoolConfig {

    //测试环境
    private static final String host = "172.26.2.18";
    //正式环境
    //private static final String host = "172.26.1.16";

    @Bean(name = {"jedisPool"})
    public JedisPool redisDataSource() {
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        // 最大空闲数
        jedisPoolConfig.setMaxIdle(10);
        // 连接池的最大数据库连接数
        jedisPoolConfig.setMaxTotal(10000);
        //资源池确保的最少空闲连接数
        jedisPoolConfig.setMinIdle(1);
        //是否开启空闲资源检测
        jedisPoolConfig.setTestWhileIdle(true);
        return new JedisPool(jedisPoolConfig, host, 6379, 2000, "Szcg@redis2023_root%#");
    }

}
